﻿using CommonEntity;
using Microsoft.AspNetCore.Mvc;
using NetCore6WebAPITestOneEntity;
using NetCore6WebAPITestOneRequestEntity;
using NetCroe6WebAPITestOneBusiness;
using System.Net;

namespace NetCroe6WebAPITestOne.Controllers
{
    [ApiController]
    [Route("UserinfoMongoDB")]
    [Produces("application/json")]
    public class UserinfoMongoDBController:ControllerBase
    {
        UserinfoMongoDbBusiness _userinfoMongoDbBusiness;

        public UserinfoMongoDBController(UserinfoMongoDbBusiness userinfoMongoDbBusiness)
        {
            _userinfoMongoDbBusiness = userinfoMongoDbBusiness;
        }

        /// <summary>
        /// 新增用户
        /// </summary>
        /// <param name="userinfo"></param>
        /// <returns></returns>
        [HttpPost("InserUserinfo")]
        [ProducesResponseType(typeof(ViewModelBase<UserinfoMongodbModel>), (int)HttpStatusCode.OK)]
        public ViewModelBase InserUserinfo([FromBody]UserinfoMongodbModel userinfo)
        {
            return _userinfoMongoDbBusiness.InserUserinfo(userinfo);
        }

        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        [HttpGet("GetUserinfo")]
        [ProducesResponseType(typeof(ViewModelBase<UserinfoMongodbModel>), (int)HttpStatusCode.OK)]
        public ViewModelBase GetUserinfo(string userid)
        {
            return _userinfoMongoDbBusiness.GetUserinfo(userid);
        }

        /// <summary>
        /// 全文检索示例
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        [HttpPost("GetUserinfoPage")]
        [ProducesResponseType(typeof(ViewModelBase<Page<UserinfoMongodbModel>>), (int)HttpStatusCode.OK)]
        public ViewModelBase GetUserinfoPage(UserinfoMongodbPageRequestViewModel para)
        {
            return _userinfoMongoDbBusiness.GetUserinfoPage(para);
        }
    }
}
